<template>
	<view>
		<view class="head">
			<view class="head-img">
				<image :src="imgSrc" mode=""></image>
			</view>
			<view class="head-msg">
				<text>{{nickname}}</text>
				<view class="head-id">
					<text>ID:</text><text>{{id}}</text>
				</view>
			</view>
		</view>
		<view class="section">
			<view class="section-top">
				<text>客户姓名</text>
				<text>{{name}}</text>
			</view>
			<view class="line">
			</view>
			<view class="section-bottom">
				<text v-if="!isModiify">手机号</text>
				<view v-if="isModiify" class="d-flex">
					<input style="width: 180rpx;" focus maxlength="15" placeholder="用户姓名" type="text" v-model="name">
				</view>
				<view class="phone">
					<view class="show_num">
						<text style="margin-right:10rpx ;" v-if="!isModiify">{{phone}}</text>
						<image v-if="!isModiify" @click="isModiify=true" src="../../static/image/write.png" mode=""></image>
					</view>
					<view v-if="isModiify" class="modify_num">
						<input style="width: 200rpx;" placeholder="电话号码" type="text" v-model="phone">
						<button class="modify_btn" type="default" size="mini" @click="submit">确认</button>
					</view>
					
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				nickname: '熬鹰的冬瓜头',
				id: '1637829',
				name: '张符朴',
				phone: '18981039441',
				isModiify:false,
				imgSrc:'',
			}
		},
		onLoad() {
			//隐藏手机号
			let that = this
			let number = this.phone; //获取到手机号码字段
			// console.log('手机号', this.phone)
			let mphone = number.substring(0, 3) + '****' + number.substring(7);
			that.phone = mphone
		},
		methods: {
			submit(){
				this.phone = this.phone.substring(0, 3) + '****' + this.phone.substring(7);
				if(this.phone == ''){
					uni.showModal({
						content:"手机号不能为空"
					})
					return
				}
				this.isModiify = false;
			},
			// getInfo(){
			// 	uni.getUserInfo({
			// 		provider: 'weixin',
			// 		success:res =>{
			// 			this.imgSrc = res.userInfo.avatarUrl;
			// 			this.nickname = res.userInfo.nickName;
			// 			this.id = res.userInfo.openId;
			// 		}
			// 	})
			// }
		}
	}
</script>

<style scoped>
	.d-flex{
		display: flex;
		justify-content: space-between;
	}
	.show_num{
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.modify_btn{
		font-size: 24rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		background: linear-gradient(142deg, #CAA022 0%, #E09926 100%);
		border-radius: 36rpx;
	}
	.modify_num{
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.head {
		width: 100%;
		height: 214rpx;
		background-color: #1F1F24;
		display: flex;
		align-items: center;
		padding-left: 60rpx;
	}

	.head-msg {
		display: flex;
		flex-direction: column;
		padding-left: 32rpx;
		/* width: 160rpx; */
		height: 160rpx;
		justify-content: space-around;
	}

	.head-img {
		width: 160rpx;
		height: 160rpx;
		background-color: #FFFFFF;
		border-radius: 80rpx;
	}

	.head-msg>text {
		color: #FFFFFF;
		font-size: 44rpx;
	}

	.head-id {
		width: 162rpx;
		height: 32rpx;
		font-size: 22rpx;
		font-family: PingFangHK-Regular, PingFangHK;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 32rpx;
		background: #DEA23D;
		display: flex;
		justify-content: center;
		border-radius: 16rpx;
	}
	
	.section{
		width: 100%;
		height: 211rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		background-color: #1F1F24;
		margin-top: 20rpx;
	}
	
	.section-top{
		width: 90%;
		height: 105rpx;
		color: #FFFFFF;
		font-size: 28rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.line{
		width: 90%;
		height: 1rpx;
		background-color: #808080;
	}
	.section-bottom{
		width: 90%;
		height: 105rpx;
		color: #FFFFFF;
		font-size: 28rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.phone image{
		width: 28rpx;
		height: 28rpx;
	}
</style>
